package com.km.team.phsystem.web.controller;

import cn.hutool.core.date.DateUtil;
import com.km.team.phsystem.beans.pojo.TimeSlotPhConfig;
import com.km.team.phsystem.beans.vo.ResponseData;
import com.km.team.phsystem.service.TimeSlotAssistService;
import com.km.team.phsystem.service.TimeSlotPhConfigService;
import com.km.team.phsystem.web.controller.base.BaseController;
import com.km.team.phsystem.web.utils.ResponseDataUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：Riven.
 * @description： 每天业务办理时段及受理数量设置
 * @date ：2018/11/30
 */
@RestController
@RequestMapping("time_slot")
public class TimeSlotPhConfigController extends BaseController<TimeSlotPhConfigController> {
    private final TimeSlotPhConfigService timeSlotPhConfigService;
    private final TimeSlotAssistService timeSlotAssistService;

    @Autowired
    public TimeSlotPhConfigController(TimeSlotPhConfigService timeSlotPhConfigService,
                                      TimeSlotAssistService timeSlotAssistService) {
        this.timeSlotPhConfigService = timeSlotPhConfigService;
        this.timeSlotAssistService = timeSlotAssistService;
    }
    @ApiOperation(value = "获取业务ID下的所有时段，忽略开启关闭状态", notes = "")
    @GetMapping("info_list/{businessId}")
    public ResponseData getTimeSlotInfoForBusiness(@PathVariable("businessId") Integer businessId) {
        return ResponseDataUtil.buildSuccess(this.timeSlotPhConfigService.getTimeSlotInfoForBusiness(businessId));
    }

    @ApiOperation(value = "根据业务ID，插入、跟新时段、临时排号表数据", notes = "")
    @PostMapping("inst_update/{businessId}/{taaNo}")
    public ResponseData instOrUpdateTimeSlot(@RequestBody List<TimeSlotPhConfig> dataList,
                                             @PathVariable("businessId") Integer businessId,
                                             @PathVariable("taaNo") Integer taaNo) {
        this.timeSlotPhConfigService.instOrUpdateTimeSlot(dataList, businessId, taaNo);
        return ResponseDataUtil.buildSuccess();
    }
    @ApiOperation(value = "根据业务ID,获取所有开启的时段排号情况", notes = "")
    @GetMapping("enable/{businessId}/{date}")
    public ResponseData getEnableTimeSlotListAndTemporaryForBusinessId(@PathVariable("businessId") Integer businessId,
                                                                        @PathVariable("date") String date) {
        return ResponseDataUtil.buildSuccess(timeSlotAssistService.getEnableTimeSlotListForBusinessId(businessId,date));
    }
}
